#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "muyusound.cpp"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setFixedSize(601,401);
    //设置标题
    setWindowTitle("扣1佛祖陪你笑");
    QPixmap backImage(":/image/fuwuqi.jpg");//添加机房佛祖
    ui->imageLabel->setPixmap(backImage);
    QPixmap *pixmap = new QPixmap(":/image/muyu.png");
    pixmap->scaled(ui->muyuLabel->size(), Qt::KeepAspectRatio);
    ui->muyuLabel->setScaledContents(true);
    ui->muyuLabel->setPixmap(*pixmap);
    ui->clickSpaceButton->setFocus(); /* 设置默认焦点 */
    /* 设置快捷键为键盘的“回车”键 */
    static int score=0;

    ui->clickSpaceButton->setShortcut ( QKeySequence::InsertParagraphSeparator );
    ui->clickSpaceButton->setShortcut ( Qt::Key_Space ); /* 设置快捷键为space键 */

    QMediaPlayer* startBackSound = new QMediaPlayer;
    startBackSound->setMedia(QUrl::fromEncoded("qrc:/audio/TianFuYue_01.mp3"));
    startBackSound->setVolume(100);
    startBackSound->play();
//    qDebug()<<"背景音乐";


    connect(ui->clickSpaceButton,&QPushButton::clicked,[=](){
      muYuSound *play=new muYuSound();
        qDebug()<<"已经new";
         score++;
        ui->gdScore->setText(QString::number(score));

    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

